<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">点击</button>
</body>
</html>
<script>
    //DOM2事件优点：事件不会被覆盖 缺点：写起来麻烦
    var btn = document.getElementById('btn');
    btn.addEventListener('click', function(){
        console.log('点击了')
    })
</script>